package com.zhuang.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Classname SubscriptionSubject
 * @Description 具体主题(具体被观察者)
 * @Date 2021/3/28 14:15
 * @Created by dell
 */

public class SubscriptionSubject implements Subject {
    //存储订阅公众号的微信用户
    private List<Observer> weixinUserList = new ArrayList<Observer>();

    @Override
    public void attach(Observer observer) {
        weixinUserList.add(observer);
    }

    @Override
    public void remove(Observer observer) {
        weixinUserList.remove(observer);
    }

    @Override
    public void notify(String messages) {
        for (Observer observer : weixinUserList) {
            observer.update(messages);
        }
    }
}
